<xsl:stylesheet version="2.0" xmlns:foo="http://something" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">

	<xsl:import href="/apps/engine/utils/translate_fct.xsl"/>

	<xsl:template match="/">
		<xhtml:html>
			<xhtml:head>
				<xhtml:title>
					<xsl:value-of select="/data/appname"/> Login</xhtml:title>
					<xhtml:link rel="stylesheet" type="text/css" href="/views/cssadds/orbeon-forms.css" />
				<xforms:model>

					<xforms:instance>
						<user xmlns="">
							<username/>
							<password/>
							<password_confirm/>
						</user>
					</xforms:instance>

					<xforms:bind nodeset="/user/username" required="true()"/>
					<xforms:bind nodeset="/user/password" required="true()"
                constraint="string-length(.) > 7"/>
					<xforms:bind nodeset="/user/password_confirm" constraint=". = ../password" required="true()"/>

					<xforms:submission id="main-submission" method="post"
                action="/register" replace="all"/>


				</xforms:model>
			</xhtml:head>
			<xhtml:body>
				<xsl:variable name="dict" select="/data/translation"/>
				<xhtml:div id="authForm">
					<xhtml:fieldset>
						<xhtml:legend>
							<xsl:value-of select="foo:translate('Create your own user account', $dict)"/>
						</xhtml:legend>
						<xsl:if test="/data/error != ''">
							<xhtml:div id="error">
								<xsl:value-of select="foo:translate(/data/error, $dict)"/>
							</xhtml:div>
						</xsl:if>
						<xhtml:div class="form_line">
							<xforms:input ref="username" incremental="true">
								<xforms:label>
									<xsl:value-of select="foo:translate('Username', $dict)"/> *</xforms:label>
							</xforms:input>
						</xhtml:div>
						<xhtml:div class="form_line">
							<xforms:secret ref="password" incremental="true">
								<xforms:label>
									<xsl:value-of select="foo:translate('Password', $dict)"/> *</xforms:label>
								<xforms:alert>
									<xsl:value-of select="foo:translate('The new password you provided is too short and must be at least composed of 8 characters.', $dict)"/>
								</xforms:alert>
							</xforms:secret>
						</xhtml:div>
						<xhtml:div class="form_line">
							<xforms:secret ref="password_confirm" incremental="true" >
								<xforms:label>
									<xsl:value-of select="foo:translate('Confirm password', $dict)"/> *</xforms:label>
								<xforms:alert>
									<xsl:value-of select="foo:translate('The new and confirmation passwords are different. Please try again.', $dict)"/>
								</xforms:alert>
							</xforms:secret>
						</xhtml:div>

						<xhtml:div class="additional_info">
							<xsl:value-of select="foo:translate('Fields labelled with * are mandatory.', $dict)"/>
						</xhtml:div>

						<xhtml:div class="submit">
							<xforms:submit submission="main-submission">
								<xforms:label>
									<xsl:value-of select="foo:translate('Create account', $dict)"/>
								</xforms:label>
							</xforms:submit>
							<xforms:trigger>
								<xforms:label>
									<xsl:value-of select="foo:translate('Reset', $dict)"/>
								</xforms:label>
								<xforms:action xmlns:ns1="http://www.w3.org/2001/xml-events" ns1:event="DOMActivate">
									<xforms:setvalue ref="/user/username"/>
									<xforms:setvalue ref="/user/password"/>
									<xforms:setvalue ref="/user/password_confirm"/>
								</xforms:action>
							</xforms:trigger>
						</xhtml:div>
					</xhtml:fieldset>
				</xhtml:div>
			</xhtml:body>
		</xhtml:html>
	</xsl:template>
</xsl:stylesheet>